package com.es.designmode.iterator;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Will
 */
public class ConcreteAggregate extends Aggregate {

    private List<Object> items = new ArrayList<Object>();

    @Override
    public Iterator createIterator() {
        return new ConcreteIterator(this);
    }

    public int count() {
        return this.items.size();
    }

    /**
     * 声明一个索引器
     *
     * @param index
     * @return
     */
    public Object getItem(int index) {
        return items.get(index);
    }

    public void addItem(Object obj) {
        items.add(obj);
    }
}
